package com.pudding.controller;

import com.pudding.service.ExcelReadService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author Pudding
 * @Date 2025/3/19 11:23
 */
@RestController
@RequestMapping("/read")
@RequiredArgsConstructor //用于自动生成一个包含所有 final 字段的有参构造函数
public class ReadController {

    private final ExcelReadService excelReadService;

    @PostMapping("/demo1")
    public void read(@RequestParam("file") MultipartFile file) {
        excelReadService.readSimpleExcel(file);
    }

    @PostMapping("/demo2")
    public void read2(@RequestParam("file") MultipartFile file) {
        excelReadService.readSimpleExcel2(file);
    }

    @PostMapping("/demo3")
    public void read3(@RequestParam("file") MultipartFile file) {
        excelReadService.readMultiSheetExcel(file);
    }

    @PostMapping("/demo4")
    public void read4(@RequestParam("file") MultipartFile file) {
        excelReadService.readMultiHeadExcel(file);
    }

    @PostMapping("/demo5")
    public void read5(@RequestParam("file") MultipartFile file) {
        excelReadService.readByConverterData(file);
    }

    @PostMapping("import")
    public void import1(@RequestParam("file")MultipartFile file){
        excelReadService.importExcel(file);
    }
}
